package com.itheima.网络编程.tcp编程.tcp编程.文件上传线程池三;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class 客户端 {
    public static void main(String[] args) throws IOException {
        while (true) {
            Socket sk = new Socket("127.0.0.1", 13333);
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入上传的文件地址:");
            String strx = sc.next();
            //String strx = "C:\\Users\\身体和心灵\\Desktop\\Spring图片\\5.png";
            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(strx));
            BufferedOutputStream bos = new BufferedOutputStream(sk.getOutputStream());
            byte[] bys = new byte[1024];
            int len;
            while ((len = bis.read(bys)) != -1) {
                bos.write(bys, 0, len);
                bos.flush();
            }
            sk.shutdownOutput();
            System.out.println("========================================================");
            BufferedReader br = new BufferedReader(new InputStreamReader(sk.getInputStream()));
            String str;
            while ((str = br.readLine()) != null) {
                System.out.println(str);
            }
            bis.close();
            bos.close();
            br.close();
            sk.close();
        }
    }
}
